﻿using System.Reflection;

namespace UniversalApproach.Models
{
    public class Properties
    {
        /// <summary>
        /// 属性名称
        /// </summary>
        public string PropertyName { get; set; }

        /// <summary>
        /// 是否为对象
        /// </summary>
        public bool IsObject { get; set; }

        /// <summary>
        /// 属性类型
        /// </summary>
        public PropertyInfo PropertyInfo { get; set; }

        /// <summary>
        /// 默认为空，不为空后续加”.“
        /// </summary>
        public string FatherPropertyName { get; set; }

        /// <summary>
        /// 全名
        /// </summary>
        /// <remarks>
        /// 若属性为可为空字段如:<see cref="int?"/>
        /// 则其全名为<see cref="FullName"/>.Value
        /// </remarks>
        public string FullName
        {
            get
            {
                if (string.IsNullOrEmpty(FatherPropertyName))
                {
                    return PropertyName;
                }
                else
                {
                    return $"{FatherPropertyName}.{PropertyName}";
                }
            }
        }
    }

}